<template>
  <div class="container">
    <div class="search-bar">
      <div class="search" @click="subSearch">
        <input type="text" disabled placeholder="搜索商品名称搜索" />
      </div>
    </div>
    <div class="classification" v-if="mallList">
      <div class="classification-nav">
        <div class="classification-nav-item" :class="{'classification-nav-active':mallActive==index}" v-if="mallList.goods_cates"
          v-for="(item,index) in mallList.goods_cates" :key="index" @click="changeMallActive(index)">
          <p>{{item.cate_title}}</p>
        </div>
      </div>
      <div class="classification-con" v-if="mallList.goods_cates && mallActive==new_goodsIndex" v-for="(new_goodsItem,new_goodsIndex) in mallList.goods_cates"
        :key="new_goodsIndex">
        <p class="fl-list-title">{{new_goodsItem.cate_title}}</p>
        <div class="c-product-list">
          <div class="fl-list">
            <div class="c-product" v-for="(item,index) in new_goodsItem._child" :key="index" @click="$router.push({ path: '/pages/classificationList/classificationList', query: { cate_id: item.id } })">
              <div class="c-product-pic">
                <img mode="widthFix" class="product-controller-icon" :src="item.img_url" />
              </div>
              <p class="c-product-name">{{item.cate_title}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    mapState,
    mapMutations
  } from "Vuex";
  // 依赖
  import request from "@/api/request";
  import {
    getMallList
  } from '@/utils/index'
  export default {
    data() {
      return {
        search: null,
        searchFocus: false
      }
    },
    computed: {
      ...mapState(['mallList', 'mallActive', 'classificationActive'])
    },
    methods: {
      ...mapMutations(['setMallList', 'setMallActive']),
      focus() {
        this.searchFocus = true
      },
      blur() {
        if (!this.search) {
          this.searchFocus = false
        }
      },
      subSearch() {
        this.$router.push({
          path: '/pages/search/search',
        })
      },
      changeMallActive(val) {
        this.setMallActive(val)
      },
    },
    mounted() {
      console.log("请求数据")
      getMallList()
    },
  }

</script>

<style lang="less">
  .container {
    flex: 1;
    display: flex;
    flex-direction: column;
  }


  .classification {
    flex: 1;
    display: flex;
  }

  .classification-nav {
    width: 80px;
    background: rgba(255, 255, 255, 1);
    overflow: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    top: 45px;

    .classification-nav-title {
      height: 98rpx;
      margin-top: 20rpx;
      display: flex;
      align-items: center;

      p {
        flex: 1;
        text-align: center;
        font-size: 15px;
      }
    }

    .classification-nav-item {
      height: 98rpx;
      display: flex;
      align-items: center;

      p {
        height: 50rpx;
        flex: 1;
        text-align: center;
        font-size: 15px;
        line-height: 50rpx;
        font-family: PingFang-SC-Regular;
        color: rgba(64, 64, 64, 1);
      }
    }
  }

  .classification-nav-active {
    background: rgba(249, 249, 249, 1);

    p {
      color: rgba(238, 117, 89, 1);
      border-left: 3px solid rgba(238, 117, 89, 1);
    }
  }

  .classification-con {
    margin-top: 45px;
    margin-left: 80px;
    background: rgba(249, 249, 249, 1);
    overflow: auto;
    height: 100%;
    flex: 1;
  }

  .c-product-list {
    padding: 0 15px;
  }

  .c-product {
    width: 100%;
    padding: 15px 0;
    border-bottom: 1rpx solid rgba(239, 239, 239, 1);

    .c-product-name {
      font-size: 26rpx;
      color: rgba(96, 96, 96, 1);
      margin-bottom: 15px;
      display: block;

    }

    .c-product-pic {
      width: 100%;
background: #F9F9F9;
      image {
        width: 100%;
      }
    }
  }

  .fl-list-title {
    font-size: 13px;
    color: rgba(96, 96, 96, 1);
    margin: 15px;
  }

  .fl-list {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    padding: 8px 4px;

    .c-product {
      width: 33.333333%;
      padding: 0 4px;
      border: 0;
      margin-bottom: 10px;

      .c-product-name {
        margin-bottom: 0px;
        text-align: center;
      }

      .c-product-pic {
        width: 100%;
        margin-bottom: 10px;
background: #F9F9F9;
        image {
          margin: 0 auto;
          display: block;
          width: 70px;
          height: 70px;
        }
      }
    }
  }

</style>
